<template>
  <div class="" style="height: 100%;">
    <beijingdatatable :header="header" :datalist="datalist"/>
  </div>
</template>
<script>
import data from "../data";

export default {
  name: "datatablebeijingrelizhan",
  components: {},
  data() {
    return {
      header: [],
      datalist: [],
    };
  },
  computed: {},
  watch: {
    "$store.state.daping.queryDbrelizhan": {
      handler: function (n, o) {
        this.loadData(n);
      },
    },
  },
  mounted() {
    // this.header = data.header1;
    // let aaa = [];
    // for (let index = 0; index < 30; index++) {
    //   _.random(0, 100)
    //   aaa.push([
    //     "计量站" + _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //     _.random(0, 100),
    //   ]);
    // }
    // this.datalist = aaa;
  },
  methods: {
    getnum(num){
      return Number(num).toFixed(2)
    },
    loadData(n) {
      this.header = data.header1;
      let aaa = [];
      for (let index = 0; index < n.length; index++) {
        let item = n[index]
        aaa.push([
          item.name,
          item['m_001t'] ? this.getnum(item['m_001t']) : '-',
          item['m_002t'] ? this.getnum(item['m_002t']) : '-',
          item['m_001p'] ? this.getnum(item['m_001p']) : '-',
          item['m_002p'] ? this.getnum(item['m_002p']) : '-',
          item['m_003q'] ? this.getnum(item['m_003q']) : '-',
          item['f_009q'] ? this.getnum(item['f_009q']) : '-',
          item['m_004t_1'] ? this.getnum(item['m_004t_1']) : '-',
          item['m_005t_1'] ? this.getnum(item['m_005t_1']) : '-',
          item['m_004p_1'] ? this.getnum(item['m_004p_1']) : '-',
          item['m_005p_1'] ? this.getnum(item['m_005p_1']) : '-',
        ]);
      }
      this.datalist = aaa;
    },
  },
};
</script>
<style lang='scss' scoped>
</style>